package com.hnhegui.backend.merchant.api;

import com.hnhegui.backend.entity.PageResult;
import com.hnhegui.backend.entity.Result;
import com.hnhegui.backend.merchant.dto.request.DeductStockRequestDTO;
import com.hnhegui.backend.merchant.dto.request.FreezeStockRequestDTO;
import com.hnhegui.backend.merchant.dto.request.ProductPageRequestDTO;
import com.hnhegui.backend.merchant.dto.request.UnfreezeStockRequestDTO;
import com.hnhegui.backend.merchant.dto.response.ProductDetailsResponseDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@FeignClient(value = "hnhegui-backend-merchant", path = "/api/products", contextId = "productRestApi")
public interface ProductRestApi {

    @PostMapping
    Result<PageResult<ProductDetailsResponseDTO>> getProductList(@RequestBody ProductPageRequestDTO request);

    @GetMapping("/{productId}")
    Result<ProductDetailsResponseDTO> getProductDetail(@PathVariable("productId") Long productId);

    //库存冻结操作
    @PostMapping("/freezeStock")
    Result<Boolean> freezeStock(@RequestBody FreezeStockRequestDTO request);

    //库存解冻操作
    @PostMapping("/unfreezeStock")
    Result<Boolean> unfreezeStock(@RequestBody UnfreezeStockRequestDTO request);

    //库存扣减操作
    @PostMapping("/deductStock")
    Result<Boolean> deductStock(@RequestBody DeductStockRequestDTO request);
}
